package fsoft.com.vn.directory.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import fsoft.com.vn.directory.dao.OrganizationDao;
import fsoft.com.vn.directory.form.Organization;

@Service
public class OrganizationServiceImpl implements OrganizationService {

	@Autowired
	private OrganizationDao OrganizationDAO;

	
	@Transactional
	public void addOrganization(Organization organization, boolean isNewAddress) {
		if (isNewAddress) OrganizationDAO.addObject(organization.getAddress());
		
		OrganizationDAO.addOrganization(organization);
	}

	@Transactional
	public List<Organization> listOrganization() {

		return OrganizationDAO.listOrganization();
	}
	
	@Transactional
	public void addObject(Object object) {
		OrganizationDAO.addObject(object);
	}
	
	@Transactional
	public List loadOjbects(String className) {
		return OrganizationDAO.loadOjbects(className);
	}
	
	@Transactional
	public Object findById(String className, int id) { 
		return OrganizationDAO.findById(className, id);
	}
}
